﻿<UserControl x:Class="MediaBrowserSL.RIA.Views.PageBooksView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:jadeControls="http://www.sebastien-alves.fr/jadeToolsSLControls"
    xmlns:MitsuControls="clr-namespace:SLMitsuControls;assembly=SLMitsuControls"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
    mc:Ignorable="d"
    xmlns:eventToCmd="clr-namespace:JulMar.Siverlight.Helpers.Interactivity;assembly=JulMar.Siverlight.Helpers"
    xmlns:julmarConverter="clr-namespace:JulMar.Silverlight.Converters;assembly=JulMar.Siverlight.Helpers"
    xmlns:julmarBindingHelpers="clr-namespace:JulMar.Siverlight.Helpers.BindingHelpers;assembly=JulMar.Siverlight.Helpers"
    d:DesignHeight="768" d:DesignWidth="1024">

    <UserControl.DataContext>
        <Binding Mode="OneWay" Path="Books" Source="{StaticResource Locator}"/>
    </UserControl.DataContext>

    <UserControl.Resources>
        <julmarConverter:NotBooleanConverter x:Key="notBooleanConverter" />

        <Storyboard x:Name="ShowGrpLeft">

            <DoubleAnimationUsingKeyFrames  BeginTime="00:00:00" Storyboard.TargetName="Grp_Left" Storyboard.TargetProperty="(FrameworkElement.Width)">
                <EasingDoubleKeyFrame KeyTime="00:00:00.6000000" Value="200">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <ElasticEase EasingMode="EaseOut" Oscillations="1"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>

            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Grp_Left" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>

        </Storyboard>

        <Storyboard x:Name="HideGrpLeft">

            <DoubleAnimationUsingKeyFrames  BeginTime="00:00:00" Storyboard.TargetName="Grp_Left" Storyboard.TargetProperty="(FrameworkElement.Width)">
                <EasingDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <ElasticEase EasingMode="EaseIn"  Oscillations="1"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>

            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.3" Storyboard.TargetName="Grp_Left" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0.5"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!--LEFT-->
        <Grid Grid.Column="0" Margin="10,10,2,10" x:Name="Grp_Left" Width="200">

            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Border Grid.Row="0" BorderThickness="1,1,1,0" CornerRadius="0,0,1,1" Background="{StaticResource BackGrdCustom}" BorderBrush="{StaticResource NormalBorderBrush}">
                <sdk:Label Content="Livres" Foreground="White" Margin="5,0,0,0" />
            </Border>

            <Border Grid.Row="1" BorderThickness="2,0,2,2" CornerRadius="0,0,4,4" Padding="4" BorderBrush="{StaticResource NormalBorderBrush}">

                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#19000000" Offset="0"/>
                        <GradientStop Color="#6656747A" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>

                <Grid>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="30"/>
                    </Grid.RowDefinitions>

                    <StackPanel x:Name="bd"
                    Grid.Row="0"
                    Orientation="Horizontal"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center">
                        <TextBox x:Name="tbSearch" Width="150" Text="{Binding MediaLookFor, Mode=TwoWay}" julmarBindingHelpers:BindingTextHelper.UpdateSourceOnChange="True" />
                    </StackPanel>

                    <ListBox x:Name="lBooks" ItemsSource="{Binding Path=MediasView}" DisplayMemberPath="Name" Grid.Row="1" 
                         Background="{x:Null}" IsEnabled="{Binding IsGenerating, Converter={StaticResource notBooleanConverter}}"
                         SelectedItem="{Binding SelectedItem, Mode=TwoWay}"/>

                    <Grid Grid.Row="2" Visibility="Visible">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
                            <jadeControls:ImageButton x:Name="btAdd" Command="{Binding PrepareAddBookCommand}" IsEnabled="{Binding IsGenerating, Converter={StaticResource notBooleanConverter}}"
                                              Source="/MediaBrowserSL.RIA;Component/Images/book_add.png" Height="20" Margin="0,0,5,0" ToolTipService.ToolTip="Ajouter un livre"/>
                            <jadeControls:ImageButton x:Name="btUp" Command="{Binding PrepareUpdateBookCommand}" IsEnabled="{Binding IsGenerating, Converter={StaticResource notBooleanConverter}}"
                                              Source="/MediaBrowserSL.RIA;Component/Images/book_edit.png" Height="20" Margin="0,0,5,0" ToolTipService.ToolTip="Modifier ce livre"/>
                            <jadeControls:ImageButton Command="{Binding DeleteBookCommand}" IsEnabled="{Binding IsGenerating, Converter={StaticResource notBooleanConverter}}"
                                              Source="/MediaBrowserSL.RIA;Component/Images/book_delete.png" Height="20" Margin="0,0,1,0" ToolTipService.ToolTip="Supprimer ce livre"/>
                        </StackPanel>
                    </Grid>
                </Grid>
                
            </Border> 

        </Grid>
        <!--LEFT-->

        <!-- CENTER -->
        <Grid Grid.Column="1" Margin="2,10,10,10">


            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Border Grid.Row="0" BorderThickness="1,1,1,0" CornerRadius="0,0,1,1" Background="{StaticResource BackGrdCustom}" BorderBrush="{StaticResource NormalBorderBrush}">
                <sdk:Label Content="Consultation" Foreground="White" Margin="5,0,0,0" />
            </Border>

            <Border Grid.Row="1" BorderThickness="2,0,2,2" CornerRadius="0,0,4,4" BorderBrush="{StaticResource NormalBorderBrush}">

                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#19000000" Offset="0"/>
                        <GradientStop Color="#6656747A" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>

                <Grid Margin="0,10,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="30" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>

                    <jadeControls:ImageButton VerticalAlignment="Center"				
        				Grid.Column="0"  Grid.Row="0" 
                        Margin="0,0,5,0"
        				Source="/MediaBrowserSL.RIA;Component/Images/Backward.png" Command="{Binding BackwardPageCommand}" CommandParameter="{Binding ElementName=book}" Height="30"/>

                    <Grid Grid.Column="1" Grid.Row="0" >
                        <Image Source="/MediaBrowserSL.RIA;Component/Images/book.png" Stretch="Fill"/>
                        <jadeControls:Loading IsLoading="{Binding IsGenerating}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                        <MitsuControls:UCBook x:Name="book" Margin="40,15" IsEnabled="{Binding IsGenerating, Converter={StaticResource notBooleanConverter}}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Loaded">
                                    <eventToCmd:EventToCommand Command="{Binding BookOpenCommand}" CommandParameter="{Binding ElementName=book}" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </MitsuControls:UCBook>
                    </Grid>

                    <jadeControls:ImageButton VerticalAlignment="Center"				
        				Grid.Column="2" Grid.Row="0" 
                        Margin="5,0,0,0"
        				Source="/MediaBrowserSL.RIA;Component/Images/Forward.png" Command="{Binding ForwardPageCommand}" CommandParameter="{Binding ElementName=book}" Height="30"/>

                    <StackPanel Grid.Row="1" Grid.ColumnSpan="3" HorizontalAlignment="Center" Orientation="Horizontal">
                        <TextBox x:Name="txCurrentPage" VerticalAlignment="Center"  Width="30" 
                                 IsEnabled="{Binding IsGenerating, Converter={StaticResource notBooleanConverter}}"
                                 Text="{Binding CurrentSheetIndex, Mode=TwoWay}" 
                                 julmarBindingHelpers:BindingTextHelper.UpdateSourceOnChange="True">
                        </TextBox>
                        <sdk:Label VerticalAlignment="Center" Margin="5,0,0,0" Content="{Binding CountPage}" Foreground="WhiteSmoke"/>

                        <jadeControls:ImageButton x:Name="zoomOut" Content="" Source="/MediaBrowserSL.RIA;Component/Images/ZoomOut.png" Margin="5,0" Width="20" Height="20">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <im:ControlStoryboardAction Storyboard="{StaticResource ShowGrpLeft}"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </jadeControls:ImageButton>

                        <jadeControls:ImageButton x:Name="zoomIn" Content="" Source="/MediaBrowserSL.RIA;Component/Images/ZoomIn.png" Margin="0,0,5,0" Width="20" Height="20">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <im:ControlStoryboardAction Storyboard="{StaticResource HideGrpLeft}"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </jadeControls:ImageButton>
                    </StackPanel>

                </Grid>



            </Border>
        </Grid>
        <!-- CENTER -->


    </Grid>
</UserControl>
